#!/bin/bash
#
# Startup script to initialize rails servers
#

# Application config
prog='fieldtrip'
app=/home/www/fieldtrip
port='3000'
env='production'
#env='test'

mongrel_rails=/usr/bin/mongrel_rails

start() {
        echo -n $"Starting $prog: "
        cd $app
        $mongrel_rails start -e $env -p $port -d
        RETVAL=$?
        echo 'Done'
        return $RETVAL
}
stop() {
        echo -n $"Stopping $prog: "
        cd $app
        $mongrel_rails stop
        RETVAL=$?
        echo 'Done'
}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        stop
        start
        ;;
  *)
        echo $"Usage: $prog {start|stop|restart}"
        exit 1
esac

exit $RETVAL
